package com.ptit.giaothong.tracnghiem;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.ptit.giaothong.HeightScores;
import com.ptit.giaothong.MainActivity;
import com.ptit.giaothong.R;
import com.ptit.giaothong.Setup;
import com.ptit.giaothong.Taskprocess;

public class TracnghiemActivity extends Activity {
	private static Button btn_1_play, btn_2_scores, btn_3_setup, btn_4_help;
	private static Activity activity;
	public static int keypager = 0;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		activity = TracnghiemActivity.this;

	}

	public static void init() {
		keypager = 0;
		activity.setContentView(R.layout.tracnghiem);
		Taskprocess.setHome(true);
		Taskprocess.setcontent("TRẮC NGHIỆM GIAO THÔNG");
		btn_1_play = (Button) activity.findViewById(R.id.play_id);
		btn_2_scores = (Button) activity.findViewById(R.id.height_srocres_id);
		btn_3_setup = (Button) activity.findViewById(R.id.setup_id);
		btn_4_help = (Button) activity.findViewById(R.id.help_id);

		btn_1_play.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				PlayGame playGame = new PlayGame(activity);
				playGame.init(1);
			}
		});

		btn_2_scores.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				HeightScores height = new HeightScores(activity);
				height.init();
			}
		});
		btn_3_setup.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Setup setup = new Setup(activity);
				setup.init();
			}
		});
		btn_4_help.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Helptracngnhiem help = new Helptracngnhiem(activity);
				help.init();
			}
		});

	}

	@Override
	public void onBackPressed() {

		switch (keypager) {
		case 0:
			MainActivity.getdialogMesg(activity, "Bạn có thực sự muốn thoát");
			break;
		case 1:
//
//			if (PlayGame.countDownTimer != null) {
//				PlayGame.countDownTimer.cancel();
//			}
			TracnghiemActivity.init();
			break;

		}

	}

	@Override
	protected void onPause() {
		super.onPause();
//		if (PlayGame.countDownTimer != null) {
//			PlayGame.countDownTimer.cancel();
//		}
	}

	@Override
	protected void onResume() {
		super.onResume();
		init();
	}

}
